﻿/* ==============================================================================
  * Description：
  * By Se7en
  * Creation Time：[2013-09-24 14:35:04]
  * @version 1.0
  * ==============================================================================*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using FrameCase.Infrastructure;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Model.Manager.DataBase;
using SystmicFunction.Public.NetService;

namespace FrameCase
{
    /// <summary>
    /// OtherCase
    /// Description：
    /// </summary>
    [TestClass]
    public class OtherCase : BaseCase
    {
        [TestMethod]
        public void Config()
        {
            //配置文件初始化一次
            DbConfiger.Provider();
        }

        [TestMethod]
        public void WcMenu()
        {
            String appId = "wx8294ddd0689cf04e";
            String appSecret = "b751859e9f1319856a6525ea691ec0d5";
            /********
             * 获取access token
             */
            String accessUrl =
                String.Format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}", appId, appSecret);

            /********
             * 
             * radBrly86LgEATxJ9jOY3o2GAFW7wvPybu71hcUGQLXE0OVBQuNzoE1B7HfAn1Lrh2f5Nep08q2KG2iPtYdSE-wp0j-0g-KmbfiR1YbK3UwZTla9TVQ2dgMk6mibvr4WmEPu_2Nk5B64ZZyFMEhi0Q
             */
            Console.WriteLine(accessUrl);
            /********
             * 
             * 
             */
            String crBtnUrl = String.Format("https://api.weixin.qq.com/cgi-bin/menu/create?access_token={0}",
                "RCOq6N5uQ4sPcyeCkqKi1WjMmGzHA-j8rkRLgqEUtU5A1nEKMjnHCB8xUnrTH8fmkt7WjL0KwFOn87st1wfSlmEYZAFc7J-QHFYL_ymEJXp8bM6Z58wWIcoOrjQXCv113YrwPYibCveX9CjVO77iQg");
            String jsonStr = "{\"button\":[{\"name\":\"关于我们\",\"sub_button\":[{\"type\":\"view\",\"name\":\"公司简介\",\"url\":\"http://www.7g7y.com/\"},{\"type\":\"view\",\"name\":\"产品简介\",\"url\":\"http://www.7g7y.com/\"}]},{\"name\":\"会员中心\",\"sub_button\":[{\"type\":\"click\",\"name\":\"会员注册\",\"key\":\"V1000_MEM_REG\"},{\"type\":\"click\",\"name\":\"我的订单\",\"key\":\"V1000_MEM_ORD\"}]},{\"type\":\"click\",\"name\":\"今日团购\",\"key\":\"V1000_TODAY_TG\"}]}";
            var response = HttpHelper.CreatePostHttpResponse(crBtnUrl, jsonStr, null, "", Encoding.UTF8, null);
            Console.WriteLine(HttpHelper.GetStr(response));
        }

        [TestMethod]
        public void WcMenuEvent()
        {
            StringBuilder output = new StringBuilder();
            String xmlString = @"<xml><ToUserName><![CDATA[gh_47b24c0bfd5d]]></ToUserName>
                        <FromUserName><![CDATA[oJbzQjilFR9ayik-hqXWyW30aNq8]]></FromUserName>
                        <CreateTime>1385744776</CreateTime>
                        <MsgType><![CDATA[event]]></MsgType>
                        <Event><![CDATA[CLICK]]></Event>
                        <EventKey><![CDATA[V1000_MEM_ORD]]></EventKey>
                        </xml>";

            using (XmlReader reader = XmlReader.Create(new StringReader(xmlString)))
            {
                while (reader.Read())
                {
                    var name = reader.Name;
                    var value = reader[reader.Name];
                }

            }
        }

        [TestMethod]
        public void DictToString()
        {
            Console.WriteLine(new Dictionary<String, String> {{"1", "2"}}.ToString());
        }






    }







}
